/**
 *
 */
package com.help10000.rms.ui.utils

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.amir.common.utils.LogUtils.Companion.E
import com.help10000.rms.common.GlobalNetWorkObserver

/**
 * @author justKeepmoving
 * @date 2016年12月29日下午3:30:29
 */
class NetWorkBroadcastReceiver : BroadcastReceiver() {
    val NET_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"

    override fun onReceive(context: Context, intent: Intent) {
        if (NET_ACTION == intent.action) {
            NetWorkUtil.cancelCountTime();
            if (!NetWorkUtil.isNetWorkAvailable()) {
                NetWorkUtil.startCountTime();
            } else {
                GlobalNetWorkObserver.cancelDialog()
            }

            E("NetWorkUtil", "网络状态改变,是否可用：" + NetWorkUtil.isNetWorkAvailable())
        }
    }
}